import maxios from '../maxios'

class commonServe {
  // 管理员登录
  login(params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `user/adminLogin`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 获取学生列表
  getAllStudentList(current, size, params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminStudent/getAllPage/${current}/${size}`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 添加学生
  addStudent(params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminStudent/addStudent`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 删除学生
  removeStudentById(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminStudent/delete/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 根据id获取学生信息
  getStudentInfo(id) {
    return new Promise((resolve, reject) => {
      maxios.get(
        `AdminStudent/getStuById/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  //   根据id修改学生信息
  changeStudentInfo(id, params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminStudent/alterStudent/${id}`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 获取待审核的申请卡列表
  getAuditList() {
    return new Promise((resolve, reject) => {
      maxios.get(
        `AdminCard/getAuditCard`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 管理员同意开卡申请
  agreeOpenCard(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminCard/agreeOpenCard/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }

  // 获取一卡通挂失列表
  getLostCard() {
    return new Promise((resolve, reject) => {
      maxios.get(
        `AdminCard/getLoseCard`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 补办或解除冻结状态
  reapplyOrRelieveCard(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `AdminCard/fillCard/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }

  //   根据学生id查询学生账单
  getStudentBill(id) {
    return new Promise((resolve, reject) => {
      maxios.get(
        `bill/getBill/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  //   根据学生id查询充值记录
  getStudentChargeInfo(id) {
    return new Promise((resolve, reject) => {
      maxios.get(
        `card/getCardCharge/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 导出账单为excel表格
  exportStudentBill(id) {
    return new Promise((resolve, reject) => {
      maxios.get(
        `bill/exportBill/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 获取所有新闻列表
  getAllNewsList() {
    return new Promise((resolve, reject) => {
      maxios.post(
        `news/getAllNews`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 发布新闻
  addNews(id, params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `news/addNews/${id}`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 根据新闻id删除新闻
  removeNewsById(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `news/deleteNews/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 获取所有建议
  getAllSuggestionList() {
    return new Promise((resolve, reject) => {
      maxios.post(
        `advice/getAllAdvice`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 根据建议id删除建议列表
  removeSuggestionById(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `advice/deleteAdvice/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 获取规章制度
  getAllRegularList() {
    return new Promise((resolve, reject) => {
      maxios.post(
        `regular/getAllRegular`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 发布规章制度
  addRegular(id, params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `regular/addRegular/${id}`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 删除规章制度
  removeRegularById(id) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `regular/deleteRegular/${id}`,
        {},
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
  // 修改规章制度
  editRegularById(params) {
    return new Promise((resolve, reject) => {
      maxios.post(
        `regular/updateRegular`,
        params,
        (res) => {
          resolve(res)
        },
        (err) => {
          reject(err)
        }
      )
    })
  }
}
export default new commonServe()
